home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The PC-SIG Library 10
/
The PC-Sig Library - Shareware for the IBM PC and Compatibles (PC-SIG)(Tenth Edition Disks 1-2804)(1991).iso
/
PC_SIGCD
/
05
/
6
/
DISK0564.ZIP
/
SOURCE.ARC
/
B.ARC
/
DOSCALL.AS
< prev
next >
Wrap
Text File
|
1986-03-29
|
2KB
|
63 lines
; general-purpose bdos gate
; written for Aztec C86 v. 3.20e
; by Jon Dart, Mar. 1986
MODEL equ 0 ;small code, small data
include lmacros.h
; unsigned int doscall(function,inptr,outptr)
; int function; struct regs *inptr,*outptr;
; /* sets ah=function #, calls dos, returns regs */
; /* also returns fn value <> 0 if carry flag set on return from dos */
; /* regptr is a pointer to a struct:
; struct regs {
; unsigned int ax,bx,cx,dx,si,di;
; }; */
codeseg segment
procdef doscall,<<arg1,word>,<arg2,word>,<arg3,word>>
pushds
push si
push di
ldptr si,arg2 ;get 2nd argument = pointer to structure.
mov ax,[si+10] ;get value of di
mov di,ax ;load it
mov bx,[si+2] ;then bx
mov cx,[si+4] ;then cx
mov dx,[si+6] ;then dx
mov ax,arg1 ;get 1st argument = function #
mov ah,al ;function # in ah
mov al,[si] ;load al from reg structure
push ax ;save ax
mov ax,[si+8] ;get value to load into si
mov si,ax ;load it
pop ax ;restore ax
int 21h ;call dos
pushf
push si
ldptr si,arg3 ;get arg3
mov [si],ax ;save ax
mov [si+2],bx ;and bx
mov [si+4],cx ;and cx
mov [si+6],dx ;and dx
mov ax,di ;get di
mov [si+10],ax ;save it
pop ax ;get si
mov [si+8],ax ;save it
popf
pop di
pop si
popds
jb errorret ;branch on carry
xor ax,ax ;normal return
pret ;return to caller
errorret:
mov ax,1 ;error return
pret
pend doscall
finish
codeseg ends
end